


#include "UF.h"

using namespace std;



int main() {
	UF<int> my_uf(10);
	key tmp = 0;
	int dat = 42;
	int* tmp_dat = NULL;

	for(int i = 0; i < 10; ++i)
	{
		my_uf.NewData(i, &dat);
	}

	tmp_dat = my_uf.RetrieveData(4);
	*tmp_dat = 77;
	cout << "chnged data of 4 from 42 to 77:\n";
	my_uf.data_print(4);
	


	cout << "\n at start:\n";
	my_uf.UF_print();
	cout << "==================================\n";

	cout << "performing union of 1 and 2:\n" << "\n";
	tmp = my_uf.Union(1,2);
	cout << "after union of 1 and 2 " << tmp << " sould be the root:\n" << "\n\n";
	my_uf.UF_print();

	cout << "\n\n performing union of 3 and 4:\n" << "\n";
	tmp = my_uf.Union(3,4);
	cout << "after union of 3 and 4 " << tmp << " sould be the root:\n" << "\n\n";
	my_uf.UF_print();

	cout << "\n\n performing union of 5 and 1:\n" << "\n";
	tmp = my_uf.Union(5,1);
	cout << "after union of 5 and 1 " << tmp << " sould be the root:\n" << "\n\n";
	my_uf.UF_print();

	cout << "\n\n performing union of 3 and 1:\n" << "\n";
	tmp = my_uf.Union(3,1);
	cout << "after union of 3 and 1 " << tmp << " sould be the root:\n" << "\n\n";
	my_uf.UF_print();


	cout << "performing Find(5), should be 1 \n";
	tmp = my_uf.Find(5);
	cout << tmp <<"\n" ; 

	cout << "performing Find(4), should be 1 \n";
	tmp = my_uf.Find(4);
	cout << tmp <<"\n" ; 

	cout << "\n\n performing union of 8 and 9:\n" << "\n";
	tmp = my_uf.Union(8,9);
	cout << "after union of 8 and 9 " << tmp << " sould be the root:\n" << "\n\n";
	my_uf.UF_print();
	cout << "4's father should be 1 \n";

	system("pause");
	return 0;
}
